/*****
  ** @file     : signal_port.c/h
  ** @brief    : 信号接口
  ** @versions : 2.1.13
  ** @time     : 2020/09/11
  ** @reviser  : unli (HeFei China)
  ** @explain  : null
*****/

#ifndef BSP_CAN_H
#define BSP_CAN_H

#ifdef __cplusplus
extern "C" {
#endif

#include "gd32f30x.h"
#include "stdbool.h"

#define CAN_RX0_INT_ENABLE 1  //CAN接收中断使能

#define CAN_MASTERR_ADD 0x20  // can主机地址

typedef struct{
    uint32_t    can_id;
    can_trasnmit_message_struct CanTx;//发送消息报文信息
    can_receive_message_struct CanRx;//接收消息报文信息
    
    uint8_t       initflag;    //CAN初始化状态
    uint8_t        motorsta;    //电机状态

    int32_t        goal_location;    //硬位置
    int32_t        goal_speed;        //硬速度
    int16_t        goal_current;    //硬电流

    bool txflag;    //CAN发送标志位
    bool rxflag;    //CAN接收标志位
}BSP_CAN_Typedef;

extern uint16_t * dec_param_reg;
extern BSP_CAN_Typedef bsp_can;

void BSP_CAN_Init(void);
ErrStatus can_send_msg(uint8_t *cmd, uint8_t len);
void can_send_data_msg(uint8_t id, uint8_t *msg, uint8_t len);

#ifdef __cplusplus
}
#endif

#endif
